package bairui.international.model.domain.jpa;

import bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord;

/**
 *
 * (用户状态纪录)TB_UserStateRecord
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_UserStateRecord#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_userStateRecord")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("用户状态纪录")
@com.lianjing.sh.processing.info.annotation.InfoComment("用户状态纪录")
public class TB_UserStateRecord
 extends TBSuper_StateVerifyRecord
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 类型 */
		public bairui.international.model.type.Type_StateRecord getType();
		/** 说明 */
		public String getCommentate();
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_UserStateRecord properties(MustProperties properties) {
		this.setType(properties.getType());
		this.setCommentate(properties.getCommentate());
		this.setUser(properties.getUser());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_UserStateRecord(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 消息 */
		public String getMessage();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_UserStateRecord properties(OptionalSingleProperties properties) {
		this.setMessage(properties.getMessage());
		return this;
	}
	
	
	
	public TB_UserStateRecord(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_UserStateRecord properties(CurrentMustProperties properties) {
		this.setUser(properties.getUser());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_UserStateRecord properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_UserStateRecord(
		@lombok.NonNull bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_UserStateRecord(
		@lombok.NonNull bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean
	) {
		update(bean);
	}
	
	public TB_UserStateRecord update(bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean){
		this.setId(bean.getId());
		this.setMessage(bean.getMessage());
		this.setType(bean.getType());
		this.setCommentate(bean.getCommentate());
		this.setCreateTime(bean.getCreateTime());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			String message = getMessage(TB_UserStateRecord.this);
			if(isOverride_getMessage){
				TB_UserStateRecord.this.setMessage(message);
			}
	
			bairui.international.model.type.Type_StateRecord type = getType(TB_UserStateRecord.this);
			if(isOverride_getType){
				TB_UserStateRecord.this.setType(type);
			}
	
			String commentate = getCommentate(TB_UserStateRecord.this);
			if(isOverride_getCommentate){
				TB_UserStateRecord.this.setCommentate(commentate);
			}
	
			bairui.international.model.domain.jpa.TB_User user = getUser(TB_UserStateRecord.this);
			if(isOverride_getUser){
				TB_UserStateRecord.this.setUser(user);
			}
		}
	
		public TB_UserStateRecord up(){
			return TB_UserStateRecord.this;
		}
	
		/** 消息 */
		private boolean isOverride_getMessage = true;
		public String getMessage(TB_UserStateRecord it) throws Exception { 
			isOverride_getMessage = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public bairui.international.model.type.Type_StateRecord getType(TB_UserStateRecord it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 说明 */
		private boolean isOverride_getCommentate = true;
		public String getCommentate(TB_UserStateRecord it) throws Exception { 
			isOverride_getCommentate = false; 
			return null;
		}
		/** 用户 */
		private boolean isOverride_getUser = true;
		public bairui.international.model.domain.jpa.TB_User getUser(TB_UserStateRecord it) throws Exception { 
			isOverride_getUser = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_UserStateRecord() {
	}
	
	public TB_UserStateRecord(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_UserStateRecord(
		@lombok.NonNull TB_UserStateRecord bean
	) {
		this.setId(bean.getId());
		this.setMessage(bean.getMessage());
		this.setType(bean.getType());
		this.setCommentate(bean.getCommentate());
		this.setCreateTime(bean.getCreateTime());
		this.setUser(bean.getUser());
		this.setCreator(bean.getCreator());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("用户")
	@com.lianjing.sh.processing.info.annotation.InfoComment("用户")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User user;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	/** get[用户] */
	public bairui.international.model.domain.jpa.TB_User getUser() {
		return this.user;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** set[用户] */
	public void setUser(bairui.international.model.domain.jpa.TB_User user) {
		this.user = user;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	public void assignUser(bairui.international.model.domain.jpa.TB_User user) {
		if(null != user){
			user.addUserStateRecords(this);
		}
		this.setUser(user);
	}
	


	
	
	

	/** take[用户] */
	public bairui.international.model.domain.jpa.TB_User takeUser(){
		if(null == this.user){
			this.user = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.user;
	}
	
	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** must[用户] */
	public bairui.international.model.domain.jpa.TB_User mustUser() {
		return this.user;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_UserStateRecord other = (TB_UserStateRecord) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
	}



}
